# src/schemas/sys_message.py
from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime


class SysMessageBase(BaseModel):
    language: str = Field(..., max_length=10, description="语言标识 zh/en/fr...")
    code: str = Field(..., description="错误码")
    description: Optional[str] = Field(..., max_length=255, description="描述")
    message: str = Field(..., max_length=500, description="翻译文本")
    remark: Optional[str] = Field(None, max_length=500,
                                  description='业务备注')


class SysMessageCreate(SysMessageBase):
    api_id: Optional[str] = Field(None, description="API主键，用于关联其他系统")


class SysMessage(SysMessageBase):
    id: str
    api_id: Optional[str]
    deletion_mark: bool = False
    deletion_reason: Optional[str]
    deletion_date: Optional[datetime]
    deletion_by: Optional[str]
    create_date: datetime
    creator_by: Optional[str]
    last_updated_date: Optional[datetime]
    last_updated_by: Optional[str]

    class Config:
        from_attributes = True      # Pydantic V2 新写法

